import Vue from 'vue'
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
import Cookies from 'js-cookie'
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import Element from 'element-ui'
import './styles/element-variables.scss'
import '@/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'
import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log
import * as filters from './filters' // global filters
import serverConfig from '@/serverConfig'
import Print from 'vue-print-nb'
import VXETablePluginExportXLSX from 'vxe-table-plugin-export-xlsx'
import ExcelJS from 'exceljs'
import VxeUI from 'vxe-pc-ui'
import 'vxe-pc-ui/lib/style.css'
import '@/styles/page.css'
import * as echarts from 'echarts'

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */
import {
  mockXHR
} from '../mock'
if (process.env.NODE_ENV === 'production') {
  mockXHR()
}

Vue.prototype.$ajaxUrl = serverConfig.production // 设置全局
Vue.prototype.imgUrlName = serverConfig.imgUrlName // 设置全局
Vue.prototype.$XSaveFile = VXETable.saveFile
Vue.prototype.Print = Print
Vue.prototype.$echarts = echarts

Vue.config.errorHandler = function (err, vm, info) {
  console.log(err)
}

store.commit('user/setAjaxUrl', serverConfig.production) // 存储到vuex中
store.commit('user/setImgUrlName', serverConfig.imgUrlName) // 存储到vuex中

Vue.use(Element, {
  size: Cookies.get('size') || 'small' // set element-ui default size
})
VXETable.use(VXETablePluginExportXLSX,{ExcelJS})
Vue.use(VXETable)
Vue.use(Print)
Vue.use(VxeUI)

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false


new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
